NETFLIX STOCK ANALYSIS¶

In [1]:
import pandas as pd

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
In [2]:
df = pd.read_csv("NFLX.csv")
In [3]:
df.head()
Out[3]:
Date Open High Low Close Adj Close Volume
0 2002-05-23 1.156429 1.242857 1.145714 1.196429 1.196429 104790000
1 2002-05-24 1.214286 1.225000 1.197143 1.210000 1.210000 11104800
2 2002-05-28 1.213571 1.232143 1.157143 1.157143 1.157143 6609400
3 2002-05-29 1.164286 1.164286 1.085714 1.103571 1.103571 6757800
4 2002-05-30 1.107857 1.107857 1.071429 1.071429 1.071429 10154200
In [4]:
sns.set(rc={'figure.figsize':(10,5)})

Making Date as an index¶

In [5]:
df['Date'] = pd.to_datetime(df['Date'])
df = df.set_index('Date')
df.head()
Out[5]:
Open High Low Close Adj Close Volume
Date
2002-05-23 1.156429 1.242857 1.145714 1.196429 1.196429 104790000
2002-05-24 1.214286 1.225000 1.197143 1.210000 1.210000 11104800
2002-05-28 1.213571 1.232143 1.157143 1.157143 1.157143 6609400
2002-05-29 1.164286 1.164286 1.085714 1.103571 1.103571 6757800
2002-05-30 1.107857 1.107857 1.071429 1.071429 1.071429 10154200

Volume of Stock Traded¶

In [6]:
sns.lineplot(x = 'Date', y = 'Volume', data = df, label  = "Volume")
plt.title("Volume of Stock vs Time ")
plt.show()
In [7]:
sns.lineplot(x = df.index, y = df['Volume'], label = 'Volume')
plt.title('Volume of stock versus time')
plt.show()
In [8]:
df.head()
Out[8]:
Open High Low Close Adj Close Volume
Date
2002-05-23 1.156429 1.242857 1.145714 1.196429 1.196429 104790000
2002-05-24 1.214286 1.225000 1.197143 1.210000 1.210000 11104800
2002-05-28 1.213571 1.232143 1.157143 1.157143 1.157143 6609400
2002-05-29 1.164286 1.164286 1.085714 1.103571 1.103571 6757800
2002-05-30 1.107857 1.107857 1.071429 1.071429 1.071429 10154200

Netlix stock price 'High, Close, Open vs Date'¶

In [9]:
df.plot(y= ['High', 'Close', 'Open'], title = "netflix stock price")
plt.show()
In [10]:
import plotly.graph_objects as go
y1 = df['High']
y2 = df['Close']
y3 = df['Open']
fig = go.Figure()
In [11]:
fig.add_trace(go.Scatter(x = df.index, y = y1, name = 'High'))
fig.add_trace(go.Scatter(x = df.index, y = y2, name = 'close'))
fig.add_trace(go.Scatter(x = df.index, y = y3, name = 'Open'))
fig.update_layout(title = "High, Close, Open vs Date", xaxis_title = "Date", yaxis_title = "High, Close, Open" )
fig.show()

Netlix stock price 'Day month, year¶

In [12]:
df.head()
Out[12]:
Open High Low Close Adj Close Volume
Date
2002-05-23 1.156429 1.242857 1.145714 1.196429 1.196429 104790000
2002-05-24 1.214286 1.225000 1.197143 1.210000 1.210000 11104800
2002-05-28 1.213571 1.232143 1.157143 1.157143 1.157143 6609400
2002-05-29 1.164286 1.164286 1.085714 1.103571 1.103571 6757800
2002-05-30 1.107857 1.107857 1.071429 1.071429 1.071429 10154200

netflix stock price in a Day¶

In [13]:
fig,(ax1,ax2,ax3) = plt.subplots(3, figsize = (15,10))
In [14]:
fig,(ax1,ax2,ax3) = plt.subplots(3, figsize = (15,10))
df.groupby(df.index.day).mean().plot(y = 'Volume', ax = ax1, xlabel = 'Day')
Out[14]:
<Axes: xlabel='Day'>
In [15]:
fig, (ax1,ax2,ax3) = plt.subplots(3,figsize = (15,10))
df.groupby(df.index.month).mean().plot(y = 'Volume', ax = ax2, xlabel = 'month')
Out[15]:
<Axes: xlabel='month'>
In [16]:
fig, (ax1,ax2,ax3) = plt.subplots(3,figsize = (15,10))
df.groupby(df.index.year).mean().plot(y = 'Volume', ax = ax3, xlabel = 'month')
Out[16]:
<Axes: xlabel='month'>

all together¶

In [17]:
fig, (ax1,ax2,ax3) = plt.subplots(3,figsize = (15,10))
df.groupby(df.index.day).mean().plot(y = 'Volume', ax = ax1, xlabel = 'Day')
df.groupby(df.index.month).mean().plot(y = 'Volume', ax = ax2, xlabel = 'Month')
df.groupby(df.index.year).mean().plot(y = 'Volume', ax = ax3, xlabel = 'Year')
Out[17]:
<Axes: xlabel='Year'>

Top 5 Dates with Highest Stock Price¶

In [18]:
df
Out[18]:
Open High Low Close Adj Close Volume
Date
2002-05-23 1.156429 1.242857 1.145714 1.196429 1.196429 104790000
2002-05-24 1.214286 1.225000 1.197143 1.210000 1.210000 11104800
2002-05-28 1.213571 1.232143 1.157143 1.157143 1.157143 6609400
2002-05-29 1.164286 1.164286 1.085714 1.103571 1.103571 6757800
2002-05-30 1.107857 1.107857 1.071429 1.071429 1.071429 10154200
... ... ... ... ... ... ...
2022-05-27 193.190002 195.250000 190.369995 195.190002 195.190002 8586000
2022-05-31 196.179993 199.949997 190.800003 197.440002 197.440002 11398500
2022-06-01 198.699997 202.740005 191.660004 192.910004 192.910004 8416200
2022-06-02 192.020004 205.470001 191.720001 205.089996 205.089996 9623100
2022-06-03 200.139999 202.949997 198.050003 198.979996 198.979996 7181700

5044 rows × 6 columns

In [19]:
a = df.sort_values(by = 'High', ascending = False).head()
a['High']
Out[19]:
Date
2021-11-17    700.989990
2021-11-19    694.159973
2021-11-18    691.739990
2021-10-29    690.969971
2021-11-01    689.969971
Name: High, dtype: float64

Top 5 dates with Lowest Stock Price¶

In [20]:
b = df.sort_values(by = 'Low', ascending = True).head(5)
b['Low']
Out[20]:
Date
2002-10-10    0.346429
2002-10-09    0.347143
2002-10-07    0.382143
2002-10-08    0.390714
2002-10-16    0.442857
Name: Low, dtype: float64

Lets make a trend¶

In [21]:
fig, axes = plt.subplots(nrows = 1, ncols = 2, sharex = True, figsize = (12,5))
fig.suptitle('High and Low Stock Per Period of time ', fontsize = 18)
sns.lineplot(ax = axes[0], y = df['High'], x = df.index,color = 'green')
sns.lineplot(ax = axes[1], y = df['Low'], x = df.index, color = 'red')
Out[21]:
<Axes: xlabel='Date', ylabel='Low'>
In [ ]: